#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
using namespace std;

#include <string.h>

int main()
{

	char str[66] = { 0 };
	scanf("%[^\n]s", str);

	int flag = 0;
	int count = 0;
	int len = strlen(str);

	//it is so 666 really 6666 what else can I say 666666666666666 and hehe.
	//it is so 666 really 9 what else can I say 27
	char* pc = str;
	for (int i = 0; i < len; i++, pc++)
	{

		if (str[i] == '6')
		{

			count++;
			if (count > 3 && count < 9)
			{
				flag = 1;
			}
			else if (count > 9)
			{
				flag = 2;
			}

		}
		else
		{

			if (flag == 1)
			{
				*(pc - 1) = '9';
				strcpy(pc - count, pc - 1);
				flag = 0;
			}
			else if (flag == 2)
			{
				*(pc - 1) = '7';
				*(pc - 2) = '2';
				strcpy(pc - count, pc - 2);				
				flag = 0;
			}
			else
				;

			count = 0;
		}

	}

	printf("%s", str);

	return 0;
}
